﻿var ns = namespace("kaskelot.web");

ns.masterpage = function () {

	function init() {
		$(window).load(function () {
			resizeContentContainer();
		});

		getValNamn();
	}

	function resizeContentContainer() {
		var selector = "#contentContainer";

		var docHeight = $(document).height();
		var topHeight = $("#top").outerHeight();
		var footerHeight = $("#footer").outerHeight();

		var fullHeight = docHeight - topHeight - footerHeight
		var currentHeight = $(selector).height();

		if (currentHeight < fullHeight)
			$(selector).css("min-height", fullHeight);
	}

	function getValNamn() {
		var method = "GetValNamn";

		$.ajax({
			url: window.location.protocol + "//" + window.location.host + "/ClientServices/ClientValService.svc/" + method,
			type: "GET",
			data: {},
			processData: true,
			cache: false,
			success: function (resp) {
				if (resp["d"].HasError) {
					alert(resp["d"].ErrorMessage);
				}
				else {
					$("#val-namn").html(resp["d"].Data);
				}
			},
			error: function (xhr) {
				//alert(xhr.responseText);
			}
		});
	}

	return {
		init: init
	}
}();